<?php
if (!defined('IN_XLP')) {
    exit('Access Denied');
}
$Document = array(
    'pageid' => 'photo-index', //页面标示
    'pagename' => '用户上传照片列表', //当前页面名称
    'mycss' => array(), //加载的css样式表
    'myjs' => array(), //加载的js脚本
	'footerjs'=>array('content/jquery.smoothConfirm','content/grid/jquery.grid-a-licious.min'),
    'head' => true, //加载头部文件
);

include getTpl('header', 'public');
?>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public');?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public');?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<!-- content -->
<section id="content"> 
<section class="main"> 
<div class="page-title"><h4><i class="fa fa-table"></i><?php echo trim($Document['pagename'],'_');?></h4></div> 
<!---->
<div class="panel-body">
<div class="row text-small">
<div class="col-sm-8">
<div class="btn-group" style="margin-left:20px">
   <a class="btn btn-default" href="<?php echo U('photo/index',array('all'=>1));?>">全部</a>
   <a class="btn btn-default" href="<?php echo U('photo/index',array('status'=>2));?>">正常</a>
   <a class="btn btn-default" href="<?php echo U('photo/index',array('status'=>1));?>">下线</a>
</div>
<div class="btn-group" style="margin-left:20px">
   <a class="btn btn-default" href="<?php echo U('photo/index',array('all'=>1));?>">全部</a>
   <?php
   foreach($useStatus as $key=>$val){
   ?>
   <a class="btn btn-default" href="<?php echo U('photo/index',array('source'=>($key+1)));?>"><?php echo $val;?></a>
   <?php
   }
   ?>
</div>
</div>
<div class="col-sm-4">
</div>
</div>
</div>
<!---->
<div class="m-t">
<style>
#gallery p{line-height:10px}
</style>
<div id="gallery" class="gallery hide"> 
<?php
if ($rs){
foreach($rs as $val){
?>
<div class="item" id="list_detail_<?php echo $val['id'];?>"> 
<a href="<?php echo $val['url']?getImgUrl($val['url']):'';?>" rel="pop" class="item-media"><img src="<?php echo $val['url']?getImgUrl(getThumb($val['url'],$size)):'';?>" /></a> 
<div class="desc"> 
<h4><?php echo $val['title']?$val['title']:'未命名';?>[<?php echo changeFileSize($val['real_size']);?>]</h4>
<p class="text-muted">用户：<a href="<?php echo U('photo/index',array('uid'=>$val['uid']));?>"><?php echo getUser($val['uid']);?></a></p>
<p class="text-muted">栏目：<a href="<?php echo U('photo/index',array('source'=>$val['source_id']+1));?>"><?php echo $useStatus[$val['source_id']];?></a></p>
<p class="text-muted">时间：<?php echo outTime($val['infotime']);?></p> 
<p class="text-muted">描述：<?php echo $val['description'];?></p>
<p class="text-muted"><a href="javascript:;" class="act-deal" rel="<?php echo $val['id'];?>"><i class="fa fa-gears"></i>处理</a><a href="javascript:;" class="delete col-lg-offset-1" rel="<?php echo $val['id'];?>"><i class="fa fa-times"></i>删除</a></p>
</div> 
</div> 
<?php
	}
}else{
  ?>
  <div class="item"> 
       <div class="desc"> 
        <h4>没有照片</h4>  
       </div> 
      </div> 
<?php
	}
	?>
     </div> 
    </div> 
    <footer class="panel-footer"> 
      <div class="row"> 
          <div class="col-sm-12 text-right text-center-sm"> 
                  <?php echo page($total,$p,'',20,'p');?>
          </div> 
      </div> 
  </footer>
   </section> 
  </section>
<!--主体 结束-->
<script>
$(function(){
	$(function () {
	$("#gallery").removeClass('hide');
    var buildGallery = function(){
        $("#gallery").gridalicious({
          animate: true,
          gutter: 15,
          width: 250
        });
    }
    buildGallery();
});
$('.act-deal').click(function(){
	var id=$(this).attr('rel');
  $(this).smoothConfirm("请选择操作类型", {
	  okVal:'恢复',
	  cancelVal:'屏蔽',
	  ok: function() {
		  Msg.loading();
		  $.getJSON('<?php echo U('photo/deal');?>',{"id":id,"do":'ok'},function(result){
			  Msg.ok('操作成功');
			  $("#list_detail_"+id).fadeOut();
		  });
	  },
	  cancel: function() {
		  Msg.loading();
		  $.getJSON('<?php echo U('photo/deal');?>',{"id":id,"do":'invalid'},function(result){
			  Msg.hide();
			  $("#list_detail_"+id).fadeOut();
		  });
	  }
  });
   $("body").click();
  return false;
})
$('.delete').click(function(){
	var id=$(this).attr('rel');
  $(this).smoothConfirm("确认删除该图片吗？", {
	  ok: function() {
		  $.post('<?php echo U('photo/delete');?>',{"id":id},function(result){
			  $("#list_detail_"+id).fadeOut();
		  },'json');
	  },
	  cancel: function() {
		  return false;
	  }
  });
   $("body").click();
  return false;
})	
})
</script>
<?php
include getTpl('footer', 'public');
?>